#include <iostream>
using namespace std;
#include "sys/clock.h"
#include "utils/time.h"
using namespace tdl;
#include "wbl/time_provider.h"
using namespace wbl;

int n = 10000000;

template <typename T>
double calc_us_per_call(T& obj)
{
	usec_t s = get_usec(get_now_utime());
	for(int i = 0; i < n; ++i)
		obj.now_ms();
	usec_t e = get_usec(get_now_utime());
	double us_per_call = (double)(e - s) / n;
	return us_per_call;
}

int main(int argc, char* argv[])
{
	tdl::thread_clock thc;
	thc.initialize(1);

	double us_per_call = calc_us_per_call(thc);
	cout << "tdl::thread_clock::now(): " << (TIME_2BAND / us_per_call) / 10000 << "w/s" << endl;

	struct timespec ts;
	usec_t s = get_usec(get_now_utime());
	for(int i = 0; i < n; ++i)
		::clock_gettime(CLOCK_MONOTONIC, &ts);
	usec_t e = get_usec(get_now_utime());
	us_per_call = (double)(e - s) / n;
	cout << "::clock_gettime(): " << (TIME_2BAND / us_per_call) / 10000 << "w/s" << endl;

	s = get_usec(get_now_utime());
	for(int i = 0; i < n; ++i)
		::time(0);
	e = get_usec(get_now_utime());
	us_per_call = (double)(e - s) / n;
	cout << "::time(): " << (TIME_2BAND / us_per_call) / 10000 << "w/s" << endl;

	struct timeval t;
	s = get_usec(get_now_utime());
	for(int i = 0; i < n; ++i)
		::gettimeofday(&t, NULL);
	e = get_usec(get_now_utime());
	us_per_call = (double)(e - s) / n;
	cout << "::gettimeofday(): " << (TIME_2BAND / us_per_call) / 10000 << "w/s" << endl;

	return 0;
}


